package menuTest;

import java.util.Scanner;

public class Menu {
	Scanner scan;
	volatile String output;
	String rm20s;
	volatile boolean rm20;

	public Menu(Scanner scan){
		this.scan = scan;
		rm20 = false;
	}

	public void showMenu(){
		System.out.println("Dette er menuen. Indtast dit valg: ");
	}
	
	public String getInput(){
		String out;
		rm20s = null;
		
		int i=0;
		while (i < 1){
			showMenu();
			output = scan.nextLine();
			if (rm20){
				i = -1;
				rm20s = output;
			}
			i++;
			try {
				Thread.sleep(50);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		out = output;
		return out;
	}

	public synchronized String rm20(){
		rm20 = true;
		System.out.println("Dette er RM20 menu. Indtast dit valg: ");
		while(rm20s == null){
			try {
				Thread.sleep(50);
			} catch (InterruptedException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		rm20 = false;
		String out = rm20s;
		rm20s = null;
		return out;
	}
}
